<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :md="6" :sm="8">
            <a-form-item label="地区">
              <j-dict-select-tag placeholder="请选择地区" v-model="queryParam.fwzId" dictCode="tb_jrtx_fwz,township_name,id"/>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <a-form-item label="批次">
              <a-input placeholder="请输入批次" v-model="queryParam.batch"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <a-form-item label="户主姓名">
              <a-input placeholder="请输入户主姓名" v-model="queryParam.loanName"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <a-form-item label="借款用途">
              <a-input placeholder="请输入借款用途" v-model="queryParam.loanUse"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8" >
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->
    
    <!-- 操作按钮区域 -->
    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange">
        <!-- 字符串超长截取省略号显示-->
        <span slot="loanUse" slot-scope="text">
          <j-ellipsis :value="text" :length="4"/>
        </span>
        <!-- 字符串超长截取省略号显示-->
        <span slot="address" slot-scope="text">
          <j-ellipsis :value="text" :length="10"/>
        </span>

      </a-table>
    </div>

  </a-card>
</template>

<script>

  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import {initDictOptions, filterMultiDictText} from '@/components/dict/JDictSelectUtil'
  import { filterObj } from '@/utils/util';
  import JEllipsis from "../../../components/jeecg/JEllipsis";
  export default {
    name: "SmallAmountPublicityAccountListBingTu",
    mixins:[JeecgListMixin],
    components: {
        JEllipsis
    },
    data () {
      return {
        description: '小额信贷（公示台账）管理页面',
        // 表头
        columns: [
          {
            title:'户主姓名',
            align:"center",
            dataIndex: 'loanName'
          },
            {
                title:'乡镇',
                align:"center",
                dataIndex: 'fwzId',
                customRender:(text)=>{
                    if(!text){
                        return ''
                    }else{
                        return filterMultiDictText(this.dictOptions['fwzId'], text+"")
                    }
                }
            },
            {
                title:'性别',
                align:"center",
                dataIndex: 'sex',
                customRender:(text)=>{
                    if(!text){
                        return ''
                    }else{
                        return filterMultiDictText(this.dictOptions['sex'], text+"")
                    }
                }
            },
          {
            title:'年龄',
            align:"center",
            dataIndex: 'age'
          },
          {
            title:'家庭住址',
            align:"center",
            dataIndex: 'address',
              scopedSlots: {customRender: 'address'},
          },
            {
                title:'信用评分',
                align:"center",
                dataIndex: 'creditScore'
            },
            {
                title:'信用等级',
                align:"center",
                dataIndex: 'creditRating',
                customRender:(text)=>{
                    if(!text){
                        return ''
                    }else{
                        return filterMultiDictText(this.dictOptions['creditRating'], text+"")
                    }
                }
            },
            {
                title:'借款金额（万元）',
                align:"center",
                dataIndex: 'loanMoney'
            },
          {
            title:'借款用途',
            align:"center",
            dataIndex: 'loanUse',
              scopedSlots: {customRender: 'loanUse'},
          },
          {
            title:'批次',
            align:"center",
            dataIndex: 'batch'
          },
            {
                title:'公示时间',
                align:"center",
                dataIndex: 'dateGs',
                customRender:function (text) {
                    return !text?"":(text.length>10?text.substr(0,10):text)
                }
            }
        ],
        url: {
          list: "/loanmanagement/smallAmountPublicityAccount/list",
          delete: "/loanmanagement/smallAmountPublicityAccount/delete",
          deleteBatch: "/loanmanagement/smallAmountPublicityAccount/deleteBatch",
          exportXlsUrl: "/loanmanagement/smallAmountPublicityAccount/exportXls",
          importExcelUrl: "loanmanagement/smallAmountPublicityAccount/importExcel",
        },
        dictOptions:{
            sex:[]
        } 
      }
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      }
    },
    methods: {
        getQueryParams() {
            //获取查询条件
            let sqp = {}
            if(this.superQueryParams){
                sqp['superQueryParams']=encodeURI(this.superQueryParams)
            }
            var param = Object.assign(sqp, this.queryParam, this.isorter ,this.filters);
            param.field = this.getQueryField();
            param.pageNo = this.ipagination.current;
            param.pageSize = this.ipagination.pageSize;

            if (param.loanUse!=undefined) {
                param.loanUse = "*" + param.loanUse + "*";
            }
            if (param.loanName!=undefined) {
                param.loanName = "*" + param.loanName + "*";
            }
            return filterObj(param);
        },
      initDictConfig(){
          initDictOptions('sex').then((res) => {
              if (res.success) {
                  this.$set(this.dictOptions, 'sex', res.result)
              }
          })
          initDictOptions('tb_jrtx_fwz,township_name,id').then((res) => {
              if (res.success) {
                  this.$set(this.dictOptions, 'fwzId', res.result)
              }
          })
          initDictOptions('credit_rating').then((res) => {
              if (res.success) {
                  this.$set(this.dictOptions, 'creditRating', res.result)
              }
          })
      }
       
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>